package com.dinadi.yidi.ui;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.dinadi.yidi.bean.UserInfoBean;
import com.dinadi.yidi.utils.ToastUtil;
import com.umeng.analytics.MobclickAgent;
import com.umeng.message.IUmengRegisterCallback;
import com.umeng.message.PushAgent;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

/**
 * Created by hc-3020-i3 on 2016/10/25.
 */
public class MyApplication extends Application {
    private static MyApplication app;
    public static Context mContext = null;


    public UserInfoBean user = new UserInfoBean();

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        app = this;
        UMShareAPI.get(this);
        // MobclickAgent.startWithConfigure();
        MobclickAgent.setScenarioType(mContext, MobclickAgent.EScenarioType.E_UM_NORMAL);
        // 友盟错误统计
        PlatformConfig.setWeixin("wxabadc79d4039e77d", "0c49e2308d74628c893124d85455e22e");
        Config.DEBUG = true;
        //初始化推送PushSDK
        PushAgent mPushAgent = PushAgent.getInstance(this);
        //注册推送服务，每次调用register方法都会回调该接口
        mPushAgent.register(new IUmengRegisterCallback() {

            @Override
            public void onSuccess(String deviceToken) {
                //注册成功会返回device token
                Log.d("deviceToken", deviceToken);
            }

            @Override
            public void onFailure(String s, String s1) {
                Log.d("deviceToken~~~", s+"~~~~~~~~"+s1);
            }
        });
        mPushAgent.setDebugMode(false);//关闭日志输出。

    }
    // 单例模式，获取application实例

    public static MyApplication getApp() {
        if (app == null) {
            app = new MyApplication();
        }
        return app;
    }

    public UserInfoBean getUser() {
        return user;
    }

    public void setUser(UserInfoBean user) {
        this.user = user;
    }
}
